<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['user'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['user'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{ 
	if(isset($_REQUEST['partyId']) && $_REQUEST['partyId'] > 0) 
	{
		$vendor = 0;
		$party = 1;
	  $selectCustomer = "SELECT partyId, companyName
                         FROM party
                        ORDER BY companyName";
    $selectCustomerRes = mysql_query($selectCustomer);
    $partyArray = array();
    $partyCount = 0;
    while($partyRow = mysql_fetch_array($selectCustomerRes))
    {
      $partyArray[$partyCount]['partyId']     = $partyRow['partyId']."P";
      $partyArray[$partyCount]['companyName'] = $partyRow['companyName'];
      $partyCount++;
    }
    $smarty->assign("partyArray",$partyArray);
  }
  if(isset($_REQUEST['vendorId']) && $_REQUEST['vendorId'] > 0)
	{
		$vendor = 1;
		$party = 0;
	  $selectSupplier = "SELECT supplierId, companyName
                         FROM supplier
                        ORDER BY companyName";
    $selectSupplierRes = mysql_query($selectSupplier);
    $supArray = array();
    $supCount = 0;
    while($suppRow = mysql_fetch_array($selectSupplierRes))
    {
      $supArray[$supCount]['partyId']     = $suppRow['supplierId']."S";
      $supArray[$supCount]['companyName'] = $suppRow['companyName'];
      $supCount++;
    }
    $smarty->assign("supArray",$supArray);
  }
  $smarty->assign("vendor",$vendor);
  $smarty->assign("party",$party);
  $smarty->display("smsGetPartyAj.tpl");
}
?>